/**
@file Entity.cpp

Includes implementation for main physics entity in the physics engine

@see Physics::CEntity

@author Carlos Fraguas
@date December, 2013
*/

#include "Entity.h"

namespace Physics {
	CEntity::CEntity(std::string name, float radius, Logic::CEntity *logicEntity)
		: _name(name), _radius(radius), _logicEntity(logicEntity) { }

	CEntity::~CEntity() {
		_logicEntity = 0;
	}

	bool CEntity::collidesWith(const CEntity *entity) const {
		float distanceX = entity->_position.x - _position.x;
		float distanceY = entity->_position.y - _position.y;
		float radiusSum = _radius + entity->_radius;

		return (distanceX * distanceX) + (distanceY * distanceY) < (radiusSum * radiusSum);
	}

	void CEntity::tick(float secs) {
		// perform any sort of physics simulation here
	}

	void CEntity::setPosition(Vector3 position) {
		_position = position;
	}

	Vector3 CEntity::getPosition() const {
		return _position;
	}
}